package maria.carne.cat;

import java.util.ArrayList;
import java.util.Random;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

public class pluja {
	
	private ArrayList<Objecte> gotes;
	private final int maxgotes = 8;
	Resources resources;
	BitmapFactory.Options options;
	Bitmap gota;
	Random rand;
	
	public pluja (Resources res) {
		resources = res;
		options = new BitmapFactory.Options();
		options.inPreferredConfig = Bitmap.Config.ARGB_8888;
		rand = new Random();
		gotes = new ArrayList<Objecte>();
		gota = BitmapFactory.decodeResource(resources, R.drawable.gota_640);
	}
	
	public void actualitza ()
	{
		if(rand.nextInt(15)==0) gotes.add(new Objecte(gota,(float)rand.nextInt(750),-50,50,50,0,3));
		for(int i=gotes.size()-1; i>=0; i--) {
			Objecte g = gotes.get(i);
			g.actualitza();
			if(g.y>VG.Screen.metrics.heightPixels) gotes.remove(i);
		}
	}
	
	public void draw(Canvas canvas) {
		for(int i=0; i<gotes.size(); i++) gotes.get(i).draw(canvas);
	}
}
